<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>后台管理模板</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="../../css/global.css" media="all">
		<link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">
		<link rel="stylesheet" href="../../datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css">
		<style type="text/css">
			label {
				font-size: 18px;
			}
			
			img {
				margin-right: 10px
			}
			
			.headitem {
				float: left;
				padding-right: 10%;
				line-height: 43px;
				font-size: 18px;
				margin-bottom: 25px;
				margin-left: 10%;
			}
			
			.ht-qq {
				margin-left: 13%;
				border-right: solid 1px;
			}
			
			.ht-dg {
				border-right: solid 1px;
			}
			
			.ht-kd {}
			
			.imgdetail {
				border-radius: 0%
			}
			
			.itemwithimg {
				line-height: 35px
			}
			
			.imgs {
				width: 160px;
				float: right;
				display: inline;
				margin-bottom: 20px;
				margin-right: 10%;
				line-height: 45px;
			}
			
			.itemtitle {
				font-size: 18px;
				float: left;
				display: inline;
			}
		</style>
	</head>

	<body>
		<div class="layui-layout layui-layout-admin" style="border-bottom: solid 5px #1aa094;">
			<!--头部导航-->
			<div class="layui-header header header-demo"></div>
			<!--左侧导航-->
			<div class="layui-side layui-bg-black" id="admin-side">
			</div>
			<!--右侧具体内容-->
			<div class="layui-body" style="bottom: 0;border-left: solid 2px #1AA094;padding:20px;z-index: -1" id="admin-body">
				<div class="title">订单详情</div>
				<hr/>
				<div class="items">
					<div class="headitem ht-qq">
						<div class="">请求方</div>
						<div class=""><img src="../../images/6.jpg" class="headPortraitUrl"><label class="nickname">小白兔</label></div>
					</div>
					<div class="headitem ht-dg">
						<div class="">代购方</div>
						<div class=""><img src="../../images/xiaosong.jpg" class="purchaseUserheadPortraitUrl"><label class="purchaseUserNickname">大灰狼</label></div>
					</div>
					<div class="headitem ht-kd">
						<div class="">快递员</div>
						<div class=""><img src="../../images/1.jpg" class="courierHeadPortraitUrl"><label class="courierNickname">大灰狼</label></div>
					</div>
					<hr>
					<div class="item itemwithimg">
						<div class="itemleft itemtitle">商品名称</div>
						<div class="imgs">
							<div id="tradeName">旺旺小小酥、一点点奶茶</div>
							<img class="imgdetail" src="../../images/0.jpg">
							<img class="imgdetail" src="../../images/0.jpg">
							<img class="imgdetail" src="../../images/0.jpg">
							<img class="imgdetail" src="../../images/0.jpg">
							<img class="imgdetail" src="../../images/0.jpg">
						</div>
					</div>
					<hr style="margin-top:20px">
					<div class="item itemwithimg">
						<div class="itemleft itemtitle">购买地点</div>
						<div class="imgs">
							<div id="purchaseStore">人民广场</div>
							<img class="imgdetail" src="../../images/0.jpg">
							<img class="imgdetail" src="../../images/0.jpg">
							<img class="imgdetail" src="../../images/0.jpg">
							<img class="imgdetail" src="../../images/0.jpg">
							<img class="imgdetail" src="../../images/0.jpg">
						</div>
					</div>
					<hr style="margin-top:20px">
					<div class="item">
						<div class="itemleft itemtitle" style="float:left;line-height:50px">收货地址</div>
						<div class="itemright" style="width:250px" id="addressDetails">浙江工商大学钱江湾生活园区流水门</div>
					</div>
					<hr>
					<div class="item">
						<label class="itemleft">小费</label><label class="itemright">￥<label id="reward">12</label></label>
					</div>
					<div class="item">
						<label class="itemleft">商品金额</label><label class="itemright">￥<lable id="trueMoney">44</lable></label>
					</div>
					<div class="item">
						<label class="itemleft">快递费</label><label class="itemright">￥<label id="courierFees">8</label></label>
					</div>
					<hr>
					<div class="item">
						<label class="itemleft">创建时间</label><label class="itemright" id="demandCreatetime">2017-7-4 19:03</label>
					</div>
					<div class="item">
						<label class="itemleft">接单时间</label><label class="itemright" id="acceptTime">2017-7-5 09:03</label>
					</div>
					<div class="item">
						<label class="itemleft">完成时间</label><label class="itemright" id="arriveTime">2017-7-7 21:03</label>
					</div>
					<hr>
					<div class="item item-assess">
						<label class="itemleft" style="float:left">评价详情</label>
						<div style="float:right;margin-right: 25px;">
							<div style="float:left"><img src="../../images/6.jpg" class="headPortraitUrl"><label class="nickname">小白兔</label></div>
							<div style="float:left;margin-left:50px">
								<div>
									<img src="../../images/xiaosong.jpg" class="purchaseUserheadPortraitUrl"><label class="purchaseUserNickname">大灰狼</label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
								</div>
								<div>
									<img src="../../images/1.jpg" class="courierHeadPortraitUrl"><label class="courierNickname">zylin</label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
								</div>
							</div>
							<hr>
							<div style="float:left"><img src="../../images/6.jpg" class="purchaseUserheadPortraitUrl"><label class="purchaseUserNickname">小白兔</label></div>
							<div style="float:left;margin-left:50px">
								<div>
									<img src="../../images/xiaosong.jpg" class="headPortraitUrl"><label class="nickname">大灰狼</label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
								</div>
								<div>
									<img src="../../images/1.jpg" class="courierHeadPortraitUrl"><label class="courierNickname">zylin</label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
									<label class="fa fa-star"></label>
								</div>
							</div>
						</div>
						<hr>
					</div>
					<div style="text-align: center;clear:both">
						<span class="layui-btn layui-btn-danger" style="margin:30px auto;clear:both;" id="closeOrder">关闭订单</span>
					</div>
				</div>
			</div>
			<!--底部导航-->
			<div class="layui-footer footer footer-demo" id="admin-footer"></div>
			<!--JS模块-->
			<script type="text/javascript" src="../../layui/layui.js"></script>
			<script src="../../js/jquery-1.12.3.min.js"></script>
			<script src="../../js/index.js"></script>
			<script src="../../layui/layui.js"></script>
			<script>
				/*var data = {
																								"orderDetail": {
																									"orderDetailInfomationView": {
																										"orderId": 12345,

																										"userId": 90173,
																										"nickname": "小白兔",
																										"headPortraitUrl": "../../images/dx.jpg",

																										"purchaseUserId": 91315,
																										"purchaseUserNickname": "大灰狼",
																										"purchaseUserheadPortraitUrl": "../../images/find_1.png",

																										"courierUserId": 93189,
																										"courierNickname": "zylin",
																										"courierHeadPortraitUrl": "../../images/fems.jpg",

																										"tradeName": "旺仔小馒头",//商品名称
																										"purchaseStore": "永辉超市",//店铺名称
																										"purchasePlace": "宝龙二期",//购买地点

																										"contacts": "zylin",//地址联系人
																										"contactsPhone": "15967175555",//联系电话
																										"address": "浙江工商大学钱江湾生活园区",//地址
																										"addressDetails": "浙江工商大学钱江湾生活园区详情",//地址详情

																										"courierFees": "10",//快递费
																										"reward": "10",//小费
																										"trueMoney": "100",//实际金额

																										"demandCreatetime": "2017-8-8 11:30",//创建时间
																										"acceptTime": "2017-8-8 11:39",//接单时间
																										"arriveTime": "2017-8-8 12:30",//送达时间

																										// "courierId": 92252,
																										// "courierAcceptTime": false,
																										// "addressId": 92730,
																										// "note": "vOCRBgTPUO",
																										"readName": "9DaYaCQ7Q3",//快递员真实姓名
																										"purchaseAddress": "mLsFYzLbTn",//发货地址
																										"type": 4704,//1 请求单 2 代购单 
																										"orderState": 77949,
																									},
																									"purchaseUserNickname": "大灰狼",
																									"purchaseUserheadPortraitUrl": "../../images/find_1.png",
																								}
																							}*/
				var orderId = window.location.href.split("?")[1].split("=")[1];
				$(function() {
					//alert(window.location.href)
					//alert(orderId)
					$.ajax({
						type: "GET",
						url: "/randomdelivery/AdminController/orderDetailInfomation/" + orderId,
						async: true,
						dateType: "json",
						contentType: "application/json",
						success: function(data) {

							//alert(JSON.stringify(data))
							orderdetail(data)
						},
						Error: function() {
							alert("服务器出错");
						}
					})

				})

				function orderdetail(data) {
					$(".nickname").text(data.orderDetail.nickname)
					$(".purchaseUserNickname").text(data.orderDetail.purchaseUserNickname)
					$(".courierNickname").text(data.orderDetail.courierNickname)
					$(".headPortraitUrl").attr('src', data.orderDetail.headPortraitUrl);
					$(".purchaseUserheadPortraitUrl").attr('src', data.orderDetail.purchaseUserheadPortraitUrl);
					$(".courierHeadPortraitUrl").attr('src', data.orderDetail.courierHeadPortraitUrl);
					$("#tradeName").text(data.orderDetail.tradeName)
					$("#purchaseStore").text(data.orderDetail.purchaseStore)
					// $("#purchasePlace").text(data.orderDetail.purchasePlace)
					$("#contacts").text(data.orderDetail.contacts)
					$("#contactsPhone").text(data.orderDetail.contactsPhone)
					//$("#address").text(data.orderDetail.address)
					$("#addressDetails").text(data.orderDetail.address)
					$("#courierFees").text(data.orderDetail.courierFees)
					$("#reward").text(data.orderDetail.reward)
					$("#demandCreatetime").text(new Date(data.orderDetail.demandCreatetime).Format("yyyy-MM-dd"))
					$("#acceptTime").text(new Date(data.orderDetail.acceptTime).Format("yyyy-MM-dd"))
					$("#arriveTime").text(new Date(data.orderDetail.arriveTime).Format("yyyy-MM-dd"))
					if(data.orderDetail.orderState==7)
					{
						
						$("#closeOrder").attr("class", "layui-btn layui-btn-disabled")
						$("#closeOrder").text("已关闭")
					}
				}

				$("#closeOrder").click(function() {
					var element = this;
					if($(element).attr("class")!="layui-btn layui-btn-disabled")
					{
					layui.use('layer', function() {
						var layer = layui.layer;
						layer.confirm('是否要关闭选中订单？', {
							icon: 2,
							title: '提示'
						}, function() {
							layer.confirm('关闭订单后不可恢复 是否仍关闭订单？', {
								icon: 2,
								title: '提示'
							}, function(index) {
								$.ajax({
									type: "POST",
									url: "/randomdelivery/AdminController/closeOrderByOrderId/" + orderId,
									async: true,
									dataType: "json",
									contentType: "application/json",
									success: function(data) {
										if(data.code == 200) {
											alert("关闭成功")
											$(element).attr("class", "layui-btn layui-btn-disabled")
											$(element).text("已关闭")
											layer.close(index);
										}
									},
									Error: function() {
										alert("服务器出错");
										layer.close(index);
									}
								})

							});

						});
					})
					}
					//alert(orderId)
					/*layui.use('layer',function()
					{
                		var layer = layui.layer;
						layer.confirm("是否要关闭该订单",
						{
							icon:2,
							title:"提示"
						},function()
						{
							
						})
					})*/

				});
			</script>
		</div>
	</body>

</html>